import yql
y = yql.Public()

monitorURL = "http://www.seomoz.org"
rssURL = "http://www.google.com/alerts/feeds/02091889458087148316/10137124638087203861"

rssQuery = "select * from feed where url='%s'" % rssURL;
rssResult = y.execute(rssQuery)

print 'Content-Type: text/plain'
print ''

def findLink(url):
	htmlQuery = "select * from html where url='%s' and xpath=@xpath" % link;
	htmlResult = y.execute(htmlQuery, {"xpath": "//a[starts-with(@href,'%s')]" % monitorURL})
	numLinks = htmlResult.count
	if numLinks == 0:
		print "No links: %s" % url
	else:
		print "links: %s" % url

maxLinks = 10;
numLinks = 0;
if rssResult.count > 1:
	for row in rssResult.rows:
		link = row.get('link').get('href')
		findLink(link)
		numLinks = numLinks + 1
		if numLinks >= maxLinks:
			break
else:
	link = rssResult.rows.get('link').get('href')
	findLink(link)